package com.lijy.superseckill.util;


import org.apache.commons.codec.digest.DigestUtils;

public class MD5Util {

    private static final String salt = "1q2w3e4r";

    public static String md5(String src) {
        return DigestUtils.md5Hex(src);
    }

    public static String firstMd5(String password) {
        String str = "" + salt.charAt(0) + salt.charAt(2) + password + salt.charAt(5) + salt.charAt(6);
        return md5(str);
    }

    public static String secondMd5(String md5Pass, String salt) {
        String str =  "" + salt.charAt(0) + salt.charAt(2) + md5Pass + salt.charAt(5) + salt.charAt(4);
        return md5(str);
    }

    public static String endMd5(String inputPassword, String saltDB) {
        String firstMd5 = firstMd5(inputPassword);
        String secondMd5 = secondMd5(firstMd5, saltDB);
        return secondMd5;
    }

    public static void main(String[] args) {
        System.out.println(firstMd5("123456"));// e5e948c8a9bfc2c3f10a55c6ce0dec86
        System.out.println(secondMd5(firstMd5("123456"), "1a2b3c4d"));
        System.out.println(endMd5("123456", "1a2b3c4d"));
    }

}
